package edu.cuit.zhuyimeng.framework.workflow.util;

import cn.hutool.extra.spring.SpringUtil;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance;

import java.util.Map;

/**
 * 工作流流程工具类
 */
public class ProcessUtils {

    /**
     * 设置流程变量
     * @param processInstance 流程实例
     * @param variableMap 流程变量
     */
    public static void setVariables(ProcessInstance processInstance, Map<String,Object> variableMap) {
        RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
        Execution execution = runtimeService.createExecutionQuery().processInstanceBusinessKey(processInstance.getBusinessKey()).singleResult();
        runtimeService.setVariables(execution.getId(),variableMap);
    }

}
